package com.ruoyi.web.controller.app.controller;

import com.ruoyi.framework.web.exception.base.XResult;
import com.ruoyi.web.controller.app.service.AppFollowService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName MyFollowController
 * @Description TODO
 * @Author tyc@yanyu
 * @Date 2018/12/10 0010 16:08
 **/
@RestController
@RequestMapping(value = "/app/myfollow")
@Api(tags = "关注")
public class AppFollowController {
    @Autowired
    private AppFollowService myFollowService;

    /**
     * 关注
     * @param memberId
     * @param otherId
     * @return
     */
    @RequestMapping(value = "addFollow",method = RequestMethod.POST)
    @ApiOperation(value = "关注",tags = "关注")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "memberId", value = "关注人ID号", required = true, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "otherId", value = "被关注人ID", required = true, dataType = "String", paramType = "query")
    })
    public XResult addFollow(String memberId,String otherId){
        return new XResult("操作成功",myFollowService.addMyFollow(memberId,otherId));
    }

    /**
     * 关注列表
     * @param memberId
     * @return
     */
    @RequestMapping(value = "queryFollowList",method = RequestMethod.POST)
    @ApiOperation(value = "关注列表",notes = "关注列表")
    @ApiImplicitParam(name = "memberId", value = "用户ID号", required = true, dataType = "String", paramType = "query")
    public XResult queryFollowList(String memberId){
        return new XResult("操作成功",myFollowService.queryFollowList(memberId));
    }

    /**
     * 取消关注
     * @return
     */
    @RequestMapping(value = "cancleFollow",method = RequestMethod.POST)
    @ApiOperation(value = "取消关注",notes = "取消关注")
    @ApiImplicitParam(name = "otherId", value = "被关注人id号", required = true, dataType = "String", paramType = "query")
    public XResult cancleFollow(String otherId){
        return new XResult("操作成功",myFollowService.updateStatus(otherId));
    }

    /***
     * 被多少人关注
     */
    @RequestMapping(value = "countNum",method = RequestMethod.POST)
    @ApiOperation(value = "统计被关注数量",notes = "统计被关注数量")
    @ApiImplicitParam(name = "otherId", value = "被关注人id号", required = true, dataType = "String", paramType = "query")
    public XResult countNum(String otherId){
        return new XResult("操作成功",myFollowService.countNum(otherId));
    }
}
